---@class Battle.BuffEffect8:Battle.BuffEffectBase
---
local BuffEffect8 = Battle.CreateClass("BuffEffect8",Battle.BuffEffectBase)
Battle.BuffEffect8 = BuffEffect8
function BuffEffect8:OnCreate(buff)
    ---@type Battle.Buffer
    self.buff = buff
    local param = decodeJsonStrToTable(self.buff.cfg.f_EffectParameter)
    self.hpPer = param[1][1]
    self.damagePer = param[1][2]
    self.actor = Battle.ActorManager.GetActor(self.buff.targetId)
    self.actor.eventSystem:Register(Battle.Event.ActorDamageBefore,self.DamageBefore,self)
end
function BuffEffect8:OnBuffStart()
    self.isActive = true
end
---@param args Battle.HitArgs
function BuffEffect8:DamageBefore(args)
    if not self.isActive then return end
    local per = 1 - self.actor:GetHp()/self.actor:GetHpMax()
    per = per * 10000
    local count = math.floor(per/self.hpPer)
    args.damageData.damage = args.damageData.damage * (1 + count * self.damagePer/10000)
    self.isActive = false
end
function BuffEffect8:OnDestroy()
    self.actor.eventSystem:UnRegister(Battle.Event.ActorDamageBefore,self.DamageBefore,self)
end

return BuffEffect8